(a). Field of the Invention
The present invention relates in general to packet forwarding in a switch controller, and more particularly to a method and apparatus which enables a switch controller to analyze and forward IP multicast packets.
(b). Description of the Prior Arts
The data unit transceived on the Internet is typically referred to as an IP packet. IP packets are divided into three types based on their destination IP addresses: broadcast packets, multicast packets and unicast packets. A unicast packet comprises an IP unicast address, which specifies a single destination, for transmitting the packet thereto from a source. Each computer on the Internet has at least an IP unicast address. A broadcast packet comprises an IP broadcast address used to send the packet from a source to all other nodes on the same local area network (LAN). A multicast packet comprises an IP multicast address used to send the packet from a source to a multiplicity of specific destinations, which can be combined as a group. Thus, the multicast address is also called a group address.
A switch may be used to forward IP packets during the packet routing process. FIG. 1 shows a block diagram of a conventional switch. FIG. 1 illustrates an example of packet forwarding in a switch 1. The switch 1 has a number of ports which connect to other network devices by physical transmission lines, such as twisted pair wiring, optical fibers, etc. The switch 1 comprises a switch controller 10 and eight ports 11-18. If a packet is received in the port 11 and forwarded to the port 15 via the controller 10, then this way of packet forwarding is unicasting (i.e. one-to-one). If a packet is received in the port 12 and broadcasted to all the ports via the controller 10, it is broadcasting (i.e. one-to-all). If a packet is received in the port 13 and forwarded to the port 15 and 16 via the controller 10, it is multicasting (i.e. selectively outputted to a specific plurality of ports).
Typically, when a switch determines how to forward a packet, it would look up a forwarding/address table, which records correspondence between MAC addresses and switch ports, to configure a port map for the packet (i.e. the port(s) which the packet is destined to), no matter which way of forwarding is concerned.
As for IP multicasting, there are two kinds of IP multicast packets, i.e. IP multicast control packets and IP multicast data packets. A switch handles these two kinds of packets in different ways. IP multicast control packets are differentiated according to the message type: router protocol packets (IGMP Query packets and multicast routing protocol packets) and group member protocol packets (IGMP Report and Leave packets). Router protocol packets, where a protocol such as IGMP, PIM, DVMRP or CBT is used, are broadcasted to all switch ports, while group member protocol packets are sent directly to router ports (i.e. ports connecting to multicast routers). An IP multicast data packet, on the other hand, involves multicast address table lookup and forwarding operations. If the table lookup returns a hit, the data packet is forwarded to all group member ports and router ports. If the multicast address is not stored in the address table (i.e. lookup miss), then the packet is broadcasted to all ports.
When a host wants to receive IP multicast traffic for a specific IP multicast address, it generates an IGMP Report packet to register its membership for the desired multicast address. A switch could learn the IP multicast group membership by monitoring IGMP Report packets. In addition to the IGMP Report message, IGMP version 2 also introduces a new type of IGMP message, the Leave message, to let the last group member cancel the multicast address registration on a multicast router faster. Multicast routers keep and refresh the membership information by generating IGMP Query packets to the All-hosts-group (IP multicast address=224.0.0.1) periodically. The switch could learn the location of multicast routers by recording the port numbers that have IGMP Query packets passed. In addition to IGMP Query packets, when the switch receives a multicast routing protocol packet, such as a PIM/DVMRP/CBT packet, the router ports can be identified as well.
However, not each conventional switch has IP multicast capability. In the prior art, a switch controller combined with a CPU is used to process IP multicast packets. But a switch without a CPU, also called dumb switch, can only perform unicasting and broadcasting, not multicasting. FIG. 3 is a diagram showing how a dumb switch forwards a packet. As shown in FIG. 3, the steps are:                321 a control logic 31 recognizing the destination MAC address of a received packet 33;        322 the control logic 31 looking up the destination MAC address in a unicast address table 30;        323 the unicast address table 30 returning a lookup result; and        324 the control logic 31 provide a port map for the packet 33 based on the lookup result.        
In the above steps, the conventional switch controller 3 compares the destination MAC address of the received packet 33 with a number of MAC unicast addresses stored in the unicast address table 30. If a hit is returned, then the packet 33 is a unicast packet and would be forwarded to the destination address; if a miss is returned, then the packet 33 is not a unicast packet and would be broadcasted to all ports of the switch controller 3. That is, the switch controller 3 cannot analyze multicast packets, and is only able to deal with unicast and broadcast packets. Therefore, a conventional switch controller needs the help of a CPU to process multicast packets.
Please refer to FIG. 2. As shown in FIG. 2, the conventional switch controller 3 provides IP multicast control packets to the CPU 2, then the CPU 2 parses the provided control protocol packets and configures multicast forwarding rules based on the parsing result. The switch controller 3 then forwards IP multicast data packets according to the configured rules. However, the design o f a switch controller combined with a CPU makes the whole system very complicated and would cost much higher. For example, an interface between the switch controller and the CPU must be added to achieve this design.